﻿using SMCL.Core.Utils.Types;
using SMCL.Core.Utils.Types.Json;

namespace SMCL.Core.Utils
{
    class DownloadTask
    {
        public string DisplayName { get; set; }
        public string Path { get; set; }
        public Uri Url { get; set; }
        public static DownloadTask FromLibrary(GameInfo_Library library, string gameVersion)
        {
            if (library.Downloads.Classifiers is null)
                return new()
                {
                    DisplayName = library.Name,
                    Path = $".minecraft\\libraries\\{library.Downloads.Artifact.Path}",
                    Url = library.Downloads.Artifact.Url
                };
            else
                return new()
                {
                    DisplayName = library.Name,
                    Path = $".minecraft\\libraries\\{library.Downloads.Classifiers.NativesWindows.Path}",
                    Url = library.Downloads.Classifiers.NativesWindows.Url
                };
        }
        public static DownloadTask FromObject(AssetIndex_Object asset)
        {
            return new()
            {
                DisplayName = asset.Name,
                Path = $".minecraft\\assets\\objects\\{asset.Path}",
                Url = asset.Url
            };
        }
    }
}